#然之协同的各种操作
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By


def demo1():
    driver = webdriver.Chrome()
    driver.get("http://localhost/ranzhi/www")
    driver.find_element(By.ID,'account').send_keys('admin')
    sleep(5)
    driver.find_element(By.ID, 'password').send_keys('123456')
    sleep(5)
    driver.find_element(By.ID, 'submit').click()
    sleep(5)
    print(driver.title)
    
    driver.close()
    driver.quit()
def demo2():
    driver = webdriver.Chrome()
    driver.get("http://localhost/ranzhi/www")
    driver.find_element(By.ID, 'account').send_keys('$qwedjx')
    sleep(5)
    driver.find_element(By.ID, 'password').send_keys('123456')
    sleep(5)
    driver.find_element(By.ID, 'submit').click()
    sleep(5)
    
    
    driver.close()
    driver.quit()


def demo3():
    driver = webdriver.Chrome()
    driver.get("http://localhost/ranzhi/www")
    driver.find_element(By.ID, 'account').send_keys('admin')
    sleep(5)
    driver.find_element(By.ID, 'password').send_keys('#123r4')
    sleep(5)
    driver.find_element(By.ID, 'submit').click()
    sleep(5)
    print(driver.title)
    
    driver.close()
    driver.quit()


def demo4():
    driver = webdriver.Chrome()
    driver.get("http://localhost/ranzhi/www")
    driver.find_element(By.ID, 'account').send_keys('')
    sleep(3)
    driver.find_element(By.ID, 'submit').click()
    sleep(3)
    print(driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div[1]/div').text)
    sleep(3)
    driver.close()
    driver.quit()


def demo5():
    driver = webdriver.Chrome()
    driver.get("http://localhost/ranzhi/www")
    driver.find_element(By.ID, 'account').send_keys('admin')
    sleep(5)
    driver.find_element(By.ID, 'password').send_keys('')
    sleep(5)
    driver.find_element(By.ID, 'submit').click()
    sleep(5)
    print(driver.title)
    
    driver.close()
    driver.quit()

from selenium.webdriver import ActionChains
from selenium.webdriver import Keys
def demo6():
    driver = webdriver.Chrome()
    driver.get("http://localhost/ranzhi/www")
    driver.find_element(By.ID, 'account').send_keys('admin')
    sleep(2)
    driver.find_element(By.ID, 'password').send_keys('123456')
    sleep(2)
    driver.find_element(By.ID, 'submit').click()
    sleep(2)
    driver.find_element(By.CSS_SELECTOR, '#s-menu-superadmin > button').click()
    sleep(2)
    driver.switch_to.frame('iframe-superadmin')
    driver.find_element(By.LINK_TEXT,'添加成员').click()
    sleep(2)
    print(driver.title)
    driver.switch_to.parent_frame()
    driver.find_element(By.CSS_SELECTOR, '#bottomRightBar > ul > li:nth-child(2) > a').click()
    sleep(3)
if __name__=='__main__':
    demo6()
